<%-- 
    Document   : list_department
    Created on : Nov 19, 2013, 11:03:37 AM
    Author     : zraj
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<script type="text/javascript">
            $.subscribe('rowselect', function(event, data) {
                //alert('Selected Row : ' + event.originalEvent.id);
                $('#hidDeptId').val(event.originalEvent.id);
                $('#form-dept-detail').submit();
            });
</script>

<s:form id="form-dept-detail" action="getDeptById" method="post">
    <s:hidden value="" id="hidDeptId" name="deptID"></s:hidden>
</s:form>
<s:form action="searchDept" method="post" theme="simple" >
    <s:label value="ค้นหา (ชื่อหน่วยงาน, รหัสหน่วยงาน)"></s:label>
    <s:textfield  value="" name="searchStr" label="ค้นหา (ชื่อหน่วยงาน, รหัสหน่วยงาน)"></s:textfield><s:submit value="Search"></s:submit>
        <br/>
</s:form>
<s:url id="remoteurl" action="listAllDept" namespace="/grid"/>
<sjg:grid
    id="gridtable"
    caption="List All Department"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="myList"
    rowList="10,15,20"
    rowNum="15"
    rownumbers="true"
    onSelectRowTopics="rowselect"
    loadonce="false"
    >

    <sjg:gridColumn name="departmentID" key="true" index="departmentID" title="รหัสหน่วยงาน" sortable="false"/>
    <sjg:gridColumn name="departmentName" index="departmentName" title="ชื่อหน่วยงาน" sortable="false"/>
   
</sjg:grid>
<div id="result"></div>
<p style="text-align: left;" >
    <s:form action="formAddDept" method="post">
          <sj:submit  value="เพิ่มข้อมูล"  button="true"></sj:submit>
    </s:form>
  
    <br/></p>